package com.ntd.study.pro.zx.ssl.socket.factory;

import com.ntd.study.pro.zx.cbpp.CfgLoader;

import javax.net.ssl.SSLSocketFactory;

public class UtilSsl {
    public static void main(String[] args) {

    }

    public static SSLSocketFactory getSslSocketFactory(){
        String jksFile= CfgLoader.properties.getProperty("JKSFILE");
//        System.setProperty("javax.net.ssl.trustStore", jksFile);
//        System.setProperty("javax.net.ssl.trustStorePassword", "123456");
//        System.setProperty("javax.net.ssl.trustStoreType", "JKS");
//        MyKeyManager keyManager = new MyKeyManager(MyKeyStoreUtil.KeyStoreType.JKS, "d:/key.p12", "123456".toCharArray());
        MyTrustManager trustManager = new MyTrustManager(jksFile, "123456".toCharArray());
        MySSLContext context = new MySSLContext("TLS", null, trustManager);
        SSLSocketFactory socketFactory = context.getSSLContext().getSocketFactory();
        return socketFactory;
    }
}
